package com.pyb.controller;

import com.pyb.pojo.User;
import jakarta.validation.Valid;
import jakarta.validation.constraints.Min;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class UserController {

    @RequestMapping("/users")
    public String show() {
        // 修正了除以零的错误
        return "index"; // 返回实际的视图名称
    }

    @RequestMapping("/login")
    public String login(@Valid User user) {
        System.out.println(user);
        return "login"; // 如果是登录成功后应该返回的视图，请使用正确的视图名称
    }

    @RequestMapping("/simpleType")
    public String simpleType(@Min(value = 0, message = "年龄不能小于0") @RequestParam("age") int age) {
        System.out.println(age);
        return "login"; // 返回实际的视图名称
    }
}